package com.hethongviet.preventingmachine.helps.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.hethongviet.preventingmachine.R;

public class DialogMessage extends Dialog
{
	private TextView mTextView = null;
	private Button mButtonBack = null;

	public DialogMessage(Context context)
	{
		super(context);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.dialog_message);

		mTextView = (TextView) findViewById(R.id.dialog_text_message);
		mButtonBack = (Button) findViewById(R.id.dialog_button_back);
	}

	/** Only message show */
	public DialogMessage(Context context, int textId)
	{
		this(context, context.getString(textId));
	}

	public DialogMessage(Context context, String text)
	{
		this(context);
		prepareResource(text);
	}

	private void prepareResource(String text)
	{
		mTextView.setText(text);
		mButtonBack.setOnClickListener(new View.OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				hide();
			}
		});
	}
	
	public void setMessage(String message)
	{
		mTextView.setText(message);
	}
}
